// 提供订单相关的api函数
import request from '@/utils/request'
/**
 * 结算页面 生成订单
 * @returns
 */
export const createOrder = () => {
  return request('/member/order/pre', 'get')
}

// 添加收货地址
/**
 *
 * @param {Object} form 添加收货地址需要的form表单
 * @returns
 */
export const addAddress = (form) => {
  return request('/member/address', 'POST', form)
}

// 修改收货地址
/**
 * @param {Object} from 添加收货地址需要的form表单
 */
export const editAddress = (form) => {
  return request(`/member/address/${form.id}`, 'put', form)
}

// 删除收货地址
/**
 * @param {Object} id 删除收货地址需要的收货地址id
 */
export const DeleteAddress = (id) => {
  return request(`/member/address/${id}`, 'DELETE')
}

/**
 * @param {Object} 提交订单
 */
export const submitOrder = (params) => {
  return request('/member/order', 'post', params)
}

/** 根据订单id查询订单详情
 * @param {String} orderId-订单id
 */
export const findOrderDetail = (orderId) => {
  return request('/member/order/' + orderId, 'GET')
}
